import Vue from 'vue';
import App from './App';
import ElementUI from 'element-ui';
import router from './router'
import axios from 'axios';
import "./util/reset.css";
import querystring from 'query-string';
import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css';
import moment from 'moment';
import wx from 'weixin-js-sdk';
import VideoPlayer from 'vue-video-player'
import {
  Toast
} from "mint-ui";
import Vant from 'vant'
import 'vant/lib/index.css'


// import {
//   Toast
// } from "mint-ui";

require('video.js/dist/video-js.css');
require('vue-video-player/src/custom-theme.css');

Vue.use(MintUI)
Vue.use(ElementUI)
Vue.use(Vant)

Vue.config.productionTip = false
Vue.prototype.$ajax = axios
Vue.prototype.wx = wx
/* eslint-disable no-new */
Vue.prototype.bus = new Vue;
Vue.use(querystring);
Vue.prototype.$moment = moment; //赋值使用

//vue移动端视频播放
Vue.use(VideoPlayer);

router.afterEach((to, from, next) => {
  window.scrollTo(0, 0)
})

axios.interceptors.response.use(
  response => {
    if (response.data.code == 5) {
      localStorage.removeItem('user');
      localStorage.removeItem('token');
      localStorage.removeItem('code');
      router.push({
        path: '/',
      })
    } else if (response.data.code == 6) {
      localStorage.removeItem('user');
      localStorage.removeItem('token');
      localStorage.removeItem('code');
      let a = localStorage.getItem('courseId');
      router.push({
        path: `/applicationform/homepage?courseId=${a}`,
      })
    } else if (response.data.code == 5005) {
      Toast(response.data.message)
      localStorage.removeItem('user');
      localStorage.removeItem('token');
      localStorage.removeItem('code');
    }
    // }else if(response.data.code == 5006){
    //   localStorage.removeItem('user');
    //   localStorage.removeItem('token');
    //   localStorage.removeItem('code');
    //   let responseMes = response.data.message
    //   router.push({ 
    //     path: `/applicationform/four`,
    //     params:{
    //      responseMes : responseMes
    //     }
    //   })
    // }
    return response;
  }
);

new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
